package com.click369.mianshiqingbao.service.impl;

import com.click369.mianshiqingbao.mapper.PaymentsBeanMapper;
import com.click369.mianshiqingbao.pojo.PaymentsBean;
import com.click369.mianshiqingbao.pojo.entity.PageResult;
import com.click369.mianshiqingbao.service.PaymentsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 用户支付信息的业务访问接口实现类
 */
@Service
public class PaymentsServiceImpl implements PaymentsService{
    @Autowired
    private PaymentsBeanMapper paymentsBeanMapper;
    /**
     * 条件分页查询用户支付信息列表
     * @return 分页查询信息的封装类对象
     */
    @Override
    public PageResult findPage(PaymentsBean paymentsbean, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<PaymentsBean> page=(Page<PaymentsBean>)paymentsBeanMapper.selectByExample(null);
        return new PageResult(page.getTotal(),page.getResult());
    }
    /**
     * 增加用户支付信息
     * @param paymentsbean 用户支付信息对象
     */
    @Override
    public void add(PaymentsBean paymentsbean) {
        paymentsBeanMapper.insert(paymentsbean);
    }
    /**
     * 根据ID获取用户支付信息对象
     * @param id 用户支付信息的id
     * @return 用户支付信息对象
     */
    @Override
    public PaymentsBean findOne(Long id) {
        return paymentsBeanMapper.selectByPrimaryKey(id);
    }
    /**
     * 修改用户支付信息
     * @param paymentsbean 用户支付信息对象
     */
    @Override
    public void update(PaymentsBean paymentsbean) {
        paymentsBeanMapper.updateByPrimaryKey(paymentsbean);
    }
    /**
     * 批量删除用户支付信息
     * @param ids 批量删除用户支付信息的id集合
     */
    @Override
    public void delete(Long[] ids) {
        for(long id:ids){
            paymentsBeanMapper.deleteByPrimaryKey(id);
        }
    }
}
